﻿using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
using T.FAS.Runtime.Base.Common;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Base.Service
{
    public class ExprLogService
    {
        readonly ExprLogDao dao = new ExprLogDao();
        public void AddDBLog(string tag, object obj)
        {
            ExprLog exprLog = new ExprLog();
            exprLog.ID = Guid.NewGuid().ToString();
            exprLog.Tag = tag;
            if (obj.GetType().Name == "String")
            {
                exprLog.Message = Convert.ToString(obj);
            }
            else
            {
                exprLog.Message = JsonConvert.SerializeObject(obj);
            }
            exprLog.Creator = UserUtil.GetCurrentUserName();
            exprLog.CreateTime = DateTime.Now;
            dao.Add(new List<object> { exprLog });
        }
    }
}
